/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#include "ImmortalChannel.h"
#include "Manager.h"
#include <system/assert.h>

namespace liba {
namespace noise {

properties::AbstractDependencyProperty* ImmortalChannel::FindProperty(const Atom& name)
{
	return channel->FindProperty(name);
}

ImmortalChannel::~ImmortalChannel()
{
	if( channel->is_finished() )
	{
		delete channel; channel = 0;
	}
	else
	{
		properties::BaseDependencyProperty<bool>* prop = channel->FindProperty<bool>(hard::Channel::loop_name);
		if (prop)
		{
			prop->Set(false);
		}
		else
		{
			LIBA_FAIL_UNEXPECTED();
		}
		Manager::make_immortal( channel ); channel = 0;
	}
}

} // namespace noise
} // namesapce liba

